﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using SapB1WebApp.DAL;
using SapB1WebApp.Utils;

namespace SapB1WebApp.DAL
{
    public class CommonDAO
    {
        /// <summary>
        /// Get Tax
        /// </summary>
        /// <returns></returns>
        public DataSet GetOVTG(string companyDB, string category)
        {
            try
            {
                DataSet dt = new DataSet("OVTG");
                SQLConnection connect = new SQLConnection(companyDB);
                List<object> lstParamValue = new List<object>();
                lstParamValue.Add(category);
                dt = connect.Excute_Query("SELECT Code, Name, Rate,Category FROM OVTG WHERE Category = @Param1 ", lstParamValue);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                throw ex;
            }
        }
        /// <summary>
        /// Get Warehouse
        /// </summary>
        /// <returns></returns>
        public DataSet GetOWHS(string companyDB)
        {
            try
            {
                DataSet dt = new DataSet("OWHS");
                SQLConnection connect = new SQLConnection(companyDB);
                dt = connect.Excute_Query("SELECT WhsCode, WhsName FROM OWHS  ", null);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                throw ex;
            }
        }
        /// <summary>
        /// Get Company
        /// </summary>
        /// <returns></returns>
        public DataSet GetAllCompany(string companyDB)
        {
            try
            {
                DataSet dt = new DataSet("SRGC");
                SQLConnection connect = new SQLConnection(companyDB);
                //dt = connect.Excute_Query("SELECT dbname,cmpname FROM [SBO-COMMON]..SRGC", null);
                dt = connect.Excute_Query("SELECT dbname,cmpname FROM SRGC", null);
                return dt;
            }
            catch (Exception ex)
            {
                Log.WriteException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "SystemError", ex);
                throw ex;
            }
        }
    }
}